<?php
/**
 * Created by PhpStorm.
 * User: mac
 * Date: 2019-02-27
 * Time: 23:12
 */

$serv = new swoole_server('127.0.0.1', 9501, SWOOLE_PROCESS, SWOOLE_SOCK_UDP);

$serv->set([
    'worker_num' => 8, //worker进程数 CPU核数的1-4倍
    'max_request' => 2000 //表示worker进程在处理完n次请求后结束运行
]);

$serv->on('Packet', function ($serv, $data, $clientInfo) {
    $serv->sendto($clientInfo['address'], $clientInfo['port'], "Server ".$data);
    var_dump($clientInfo);
});

$serv->start();